#!perl -Ilib

BEGIN {
  $ENV{SVNTRAC_TEST_USE_ROSEDBRC} = 1;
  
  require 't/_sqlite.pl';
}

use Test::More;
use Test::Differences;

plan ( tests => 1 + 6 );

use_ok ( 'SVNTrac::Ticket::Manager' );

for ( SVNTrac::Ticket::Manager->get_tickets ( query => [ extra4 => '1.0.0', status => 'closed' ] ) ) {
  eq_or_diff ( [ map { $_->tn } @$_ ], [ 1, 2, 3, 4 ], 'numbers for closed tickets for 1.0.0 (all)' );
}

for ( SVNTrac::Ticket::Manager->get_tickets ( query => [ extra4 => '1.0.0', status => 'closed', type => 'code' ] ) ) {
  eq_or_diff ( [ map { $_->tn      } @$_ ], [ 2, 4                           ], 'numbers for closed tickets for 1.0.0 (code)'  );
  eq_or_diff ( [ map { $_->contact } @$_ ], [ 'Odile Deray', 'Emile Gravier' ], 'contacts for closed tickets for 1.0.0 (code)' );
}

for ( SVNTrac::Ticket::Manager->get_tickets ( query => [ extra4 => '1.1.0', status => 'closed' ] ) ) {
  eq_or_diff ( [ map { $_->tn } @$_ ], [ 5 ], 'numbers for closed tickets for 1.1.0 (all)' );
}

for ( SVNTrac::Ticket::Manager->get_tickets ( query => [ extra4 => '1.1.0', status => 'closed', type => 'code' ] ) ) {
  eq_or_diff ( [ map { $_->tn      } @$_ ], [ 5              ], 'numbers for closed tickets for 1.1.0 (code)'  );
  eq_or_diff ( [ map { $_->contact } @$_ ], [ 'Simon Jeremi' ], 'contacts for closed tickets for 1.1.0 (code)' );
}
